package com.lzs.kunei.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lzs.entity.AllocationDetail;
import com.lzs.kunei.mapper.AllocationDetailMapper;
import com.lzs.kunei.service.AllocationDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzs.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wpy
 * @since 2020-11-24
 */
@Service
public class AllocationDetailServiceImpl extends ServiceImpl<AllocationDetailMapper, AllocationDetail> implements AllocationDetailService {
    @Autowired
     private AllocationDetailMapper allocationDetailMapper;
    @Override
    public Boolean comIsExist(String no, String locode, String combar,Integer qty) {
        QueryWrapper<AllocationDetail> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("allocationno",no);
        queryWrapper.eq("locatorcode",locode);
        queryWrapper.eq("commoditybar",combar);
        List<AllocationDetail> allocationDetails = allocationDetailMapper.selectList(queryWrapper);
        if (allocationDetails!=null&&allocationDetails.size()>0){
            AllocationDetail allocationDetail = allocationDetails.get(0);
            Integer qty1 = allocationDetail.getQty();
            AllocationDetail allocationDetail1 = new AllocationDetail();
            allocationDetail1.setQty(qty1+qty);
            allocationDetailMapper.update(allocationDetail1,queryWrapper);
            return true;
        }else {
        return false;}
    }


}
